<?php
include( "agent/onlinebet_header.php" );
if ($curruser['acl'] != 255)
{
    $userlist = GetUserList($curruser['id']);
    if ($userlist == "")
    {
        $ui->showErrorPage("<p>还没有建立会员！</p>");
        exit();
    }
}
$g_disk_code = array(1 => "a", 2 => "b", 3 => "c", 4 => "d");
$disk_code = "a";
$diskStr = "";
if (0 < $disk)
{
    $disk_code = $g_disk_code[$disk];
    $diskStr = $disk_code;
}
include( "class_6h/BetTotal_6h.php" );
$BetTotal_6h = new BetTotal_6h($lotto_id);
$betids = array(19);
$colors = array("", "red", "blue", "green");
$dataTotalArr = array();
$showDataArr = array();
$lostwin = array();
$i = 1;
while ($i < 12)
{
    $showDataArr[$i] = array();
    $showDataArr[$i]['1'] = array("numbers" => "{$i}_1", "totalnum" => 0, "amount" => 0, "amount_rate" => 0, "rate" => 0, "back1" => 0, "back2" => 0, "winlost" => 0, "namount" => "");
    $showDataArr[$i]['2'] = array("numbers" => "{$i}_2", "totalnum" => 0, "amount" => 0, "amount_rate" => 0, "rate" => 0, "back1" => 0, "back2" => 0, "winlost" => 0, "namount" => "");
    $dataTotalArr[$i] = array("bettype" => $i, "totalnum" => 0, "amount" => 0, "amount_rate" => 0, "back1" => 0, "back2" => 0);
    ++$i;
}
$theacl = $curruser['acl'];
$userid = $curruser['id'];
$showid = $theacl == 255 ? "0" : $userid;
$bettypeStr = "19";
$sql = $BetTotal_6h->getDataListByNumSsSQL($lotto_id, $bettypeStr, $showid, $diskStr, $split, $ratemod);
$rs = getdb($sql);
$updatetime = systime() - 30;
while (!$rs->eof)
{
    $bettype = $rs->f['bettype'];
    $n = substr($rs->f['numbers'], 0, 1);
    $i = intval(substr($rs->f['numbers'], 2, 2));
    $showDataArr[$i][$n]['totalnum'] = $rs->f['totalnum'];
    $showDataArr[$i][$n]['amount'] = $rs->f['amount'];
    $showDataArr[$i][$n]['amount_rate'] = $rs->f['amount_rate'];
    $showDataArr[$i][$n]['rate'] = $rs->f['rate'];
    $showDataArr[$i][$n]['back1'] = $rs->f['back1'];
    $showDataArr[$i][$n]['back2'] = $rs->f['back2'];
    $showDataArr[$i][$n]['winlost'] = 0;
    if ($updatetime < $rs->f['updatetime'])
    {
        $showDataArr[$i][$n]['namount'] = " class=\"namount\"";
    }
    $dataTotalArr[$i]['totalnum'] += $rs->f['totalnum'];
    $dataTotalArr[$i]['amount'] += $rs->f['amount'];
    $dataTotalArr[$i]['back1'] += $rs->f['back1'];
    $dataTotalArr[$i]['back2'] += $rs->f['back2'];
    $rs->next();
}
$rs->close();
if ($ratemod == 0)
{
    $rs = getdb("select * from rate1{$disk_code} where lotto_id={$lotto_id}");
    if ($rs->eof)
    {
        exit("Error ID!");
    }
    if ($theacl < 6)
    {
        $rs1 = get_srates_data($curruser['id'], $lotto_id, 1);
        $i = 1;
        while ($i < 12)
        {
            $showDataArr[$i][1]['rate'] = $rs->f["r19_1_" . d2($i)] - $rs1->f["r19_1_" . d2($i)] - 0;
            $showDataArr[$i][2]['rate'] = $rs->f["r19_2_" . d2($i)] - $rs1->f["r19_2_" . d2($i)] - 0;
            ++$i;
        }
        $rs1->close();
    }
    else
    {
        $i = 1;
        while ($i < 12)
        {
            $showDataArr[$i][1]['rate'] = $rs->f["r19_1_" . d2($i)] - 0;
            $showDataArr[$i][2]['rate'] = $rs->f["r19_2_" . d2($i)] - 0;
            ++$i;
        }
    }
    $rs->close();
}
$i = 1;
while ($i < 12)
{
    $showI = str_pad($i, 2, "0", STR_PAD_LEFT);
    $list = "<tr class=td2>";
    $list .= "<td class=td15 align=center>中</td>";
    $temp = round($dataTotalArr[$i]['amount'] - $showDataArr[$i]['1']['amount_rate'] - $dataTotalArr[$i]['back1'] + $dataTotalArr[$i]['back2']);
    if (isset($showDataArr[$i]['1']['totalnum']))
    {
        $alert = $showDataArr[$i]['1']['namount'];
        $list .= "<td align=right>" . $showDataArr[$i]['1']['totalnum'] . "</td>";
        $list .= "<td align=right {$alert}><a href=" . get_listurl2($open, 19, "1_{$showI}", 0) . ">" . round($showDataArr[$i]['1']['amount']) . "</a></td>";
    }
    else
    {
        $list .= "<td align=right> 0</td>";
        $list .= "<td align=right> 0</td>";
    }
    $list .= "<td align=right> " . $showDataArr[$i]['1']['rate'] . "</td>";
    if ($temp < 0)
    {
        $list .= "<td align=right><font color='#EE2200'>" . $temp . "</font></td></tr>";
    }
    else
    {
        $list .= "<td align=right><font color='#00AA22'>" . $temp . "</font></td></tr>";
    }
    $list .= "<tr class=td2>";
    $list .= "<td class=td15 align=center>不中</td>";
    $temp = round($dataTotalArr[$i]['amount'] - $showDataArr[$i]['2']['amount_rate'] - $dataTotalArr[$i]['back1'] + $dataTotalArr[$i]['back2']);
    if (isset($showDataArr[$i]['2']['totalnum']))
    {
        $alert = $showDataArr[$i]['2']['namount'];
        $list .= "<td align=right>" . $showDataArr[$i]['2']['totalnum'] . "</td>";
        $list .= "<td align=right {$alert}><a href=" . get_listurl2($open, 19, "2_{$showI}", 0) . ">" . round($showDataArr[$i]['2']['amount']) . "</a></td>";
    }
    else
    {
        $list .= "<td align=right> 0</td>";
        $list .= "<td align=right> 0</td>";
    }
    $list .= "<td align=right> " . $showDataArr[$i]['2']['rate'] . "</td>";
    if ($temp < 0)
    {
        $list .= "<td align=right><font color='#EE2200'>" . $temp . "</font></td></tr>";
    }
    else
    {
        $list .= "<td align=right><font color='#00AA22'>" . $temp . "</font></td></tr>";
    }
    $list .= "<tr class=td6>";
    $list .= "<td class=td0 align=right>合计</td>";
    $list .= "<td align=right>" . intval($dataTotalArr[$i]['totalnum']) . "</td>";
    $list .= "<td align=right>" . round($dataTotalArr[$i]['amount']) . "</td><td></td><td></td></tr>";
    $tpl->set("list19_{$showI}", $list);
    ++$i;
}
$tpl->load("main", "onlinebet0.htm");
$tpl->show("main");
$ui->footer();